<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body ng-app="app" ng-controller="weibo">
		<div ng-repeat="reply in replies ">
			{{reply.id}}
			{{reply.time*1000|date:"yyyy-MM-dd HH:mm:ss"}}
			<!--修改时间-->
		</div>
		<textarea ng-model="inputtext"></textarea>
		<button ng-click="submitMsg()">提交</button>
		<div ng-show="replies.length==0">暂无留言</div>
		<a href="" ng-repeat="i in pages" ng-click="getpage(i)">{{i}}</a>
		<script type="text/javascript" src="../js/angular.js" ></script>
		<script>
			var app=angular.module("app",[]);
			app.controller('weibo',function($scope,$http){
				//首先规划数据，首先是微博回复
			//	$scope.replies=[{id:1,content:2,time:1498207325949},{id:2,content:2}]
				$scope.replies=[];
				/*显示留言*/
				function getpage(p){
				$http.get('sss.php',{
					params:{act:'get',page:p}
				}).success(function(arr){
					$scope.replies=arr;
				}).error(function(){
				});
				
				alert(p);
				}
	
				getpage(1);
				$scope.getpage=getpage;
				
				/*提交留言*/
				$scope.submitMsg=function(){
					$http.get('weibobi.php',{
						params:{act:'add',content:$scope.inputtext}
					}).success(function(res){
						$scope.replies.push({
							id:res.id,
							content:$scope.inputtext,
							acc:0,
							ref:0
						})//push是往前贴可以用unshift
						if($scope.replies.length>6){
							$scope.replies.pop();//pop() 方法用于删除并返回数组的最后一个元素
						}
						$scope.inputtext="";
					}).error(function(){
						
					})
				}
				//页码
				$scope.pages=[1,2,3];
				
				//顶和踩
				$scope.fnAcc=function(id){
					$htpp.get('weibo.php',{
						params:{
							act:"acc",
							id:id
						}
					}
					)
				}
				
				
			})
		</script>
	</body>
</html>
